﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ScheduleMaker.DB.Domain;
using ScheduleMaker.DB;
using ScheduleMaker.DB.CoreDAO;
using ScheduleMaker.ConfigManager;
using ScheduleMaker.DB.Domain.Core;

namespace ScheduleMaker
{
    public partial class smAdmOvergroupAdd : Form
    {
        smAdminForm parentForm;

        public smAdmOvergroupAdd(smAdminForm _parentForm)
        {
            InitializeComponent();
            this.parentForm = _parentForm;
        }

        private void addOverGroup_Click(object sender, EventArgs e)
        {
            // Dodawanie nowej bloku
            CategoryDAO categotyDAO = DAOFactory.getCategoryDAO(ConfigManager.ConfigManager.getConfiguration().Type);

            if (ConfigManager.ConfigManager.getConfiguration().Type == Mode.University)
            {
                DB.Domain.Core.Category category = new CategoryUniversity();

                category.Name = tbOverGroupName.Text;
                category.Subjects = new List<Subject>();

                categotyDAO.save(category);

            }

            MessageBox.Show("Blok zajęć został dodany", "Dodanie bloku", MessageBoxButtons.OK, MessageBoxIcon.Information);

            this.parentForm.getCategortyList();
            this.Dispose();
        }
    }
}
